/**
 * Dear programmer:
 * When I wrote this code, only god and I knew how it worked.
 * Now, only god knows it!
 *
 * @author: Pegasus  Date: 2019-02-13 Time: 23:12
 *
 */
import {RequestAction, RequestMethod} from "../configuration/RequestConfiguration"
import {AppRequestPath} from "../configuration/AppConfig"
import {API_PROCEDURE2} from "../constant/API"
import global from "../configuration/global";

/**
 * 获取数据源
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestGetDs = (action, str,page) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveRepair",
            "jn" : str,
            "jnJson3" : "listWithPage",
            "rows":"20",
            "page":page,
            "sidx":"urgent",
            "sord":"desc ,create_datetime desc",
        },
        action
    )
};

/**
 * 获取数据源
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestGetDs_R = (action, str,page) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "WHSKRetrieveOrderImmediateByUserid",
            "jn" : str,
            "jnJson2":"{}",
            // "jnJson3" : "listWithPage",
            // "rows":"20",
            // "page":page,
            // "sidx":"room",
            // "sord":"asc",
        },
        action
    )
};

/**
 * 获取工单状态
 * @param action
 * @returns {*}
 */
export const  requestGetStatus = (action)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveRepairStatus",
            "jn" : "{}",
            "jnJson2":"{}",
            "jnJson3" : "list",
        },
        action
    )
};

export const  requestGetRole = (action)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveRole",
            "jn" : "{}",
            "jnJson2":"{}",
            "jnJson3" : "list",
        },
        action
    )
};

export const  requestGetArea = (action)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveArea",
            "jn" : '{"arg":{"SQLfields":""},"where":{"directory":"2"}}',
            "jnJson2":"{}",
            "jnJson3" : "list",
        },
        action
    )
};

/**
 * 详情数据源
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestGetDetailDs = (action, str) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRepairRecordData",
            "jn" : str,
            "jnJson2" : '{}',
        },
        action
    )
};

/**
 * 详情数据源
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestSave = (action, str) => {
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRepairRecordNew",
            "jn" : str,
            "jnJson2" : '{}',
        },
        action
    )
};

/**
 * 获取选择处理人
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestGetDealPeople = (action, str)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveEngineer",
            "jn" : str,
            "jnJson2" : '{}',
            "jnJson3" : "list",
        },
        action
    )
};

/**
 * 获取选择处理人
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestToEditOrder = (action, str)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRepairRecordEdit",
            "jn" : str,
            "jnJson2" : '{}',
        },
        action
    )
};



/**
 * 获取耗材数据源
 * @param action
 * @param str 条件
 * @returns {*}
 */
export const requestRetrieveMaterial = (action, str)=>{
    return RequestAction(
        AppRequestPath() + API_PROCEDURE2,
        RequestMethod.Post,
        {
            "hotelId": global.hotelId,
            "fu" : "QmsRetrieveMaterial",
            "jn" : str,
            "jnJson2" : '{}',
            "jnJson3" : "list",
        },
        action
    )
};

